<template>
    <div>
        <div>
            <p>游戏：<input type="text" v-model="yxname"></p>
            <p><input type="button" value="修改" @click="upyx()"></p>
        </div>
        <div>
            <p>英雄：<input type="text" v-model="usernmae"></p>
            <p>密码：<input type="password" v-model="password"></p>
            <p>头像：<input type="file" @change="getfile($event)"></p>
            <p>
                <select v-model="ssd">
                    <option v-for="(i,j) in yxlist" :value="i.id" :key="j">{{i.yxname}}</option>
                </select>
            </p>
            <p><input type="button" value="添加" @click="upus()"></p>
        </div>
    </div>
</template>

<script>
import axios from 'axios'
import { RI_yx_upd } from '../axios_send/api.js'
import { RI_us_upd } from '../axios_send/api.js'
import { RI_res_yxsh } from '../axios_send/api.js'
export default {
    name:"upss",
    data(){
        return{
            yxname:"",
            usernmae:"",
            password:"",
            yxlist:"",
            ssd:"",
        }
    },
    created(){
        this.yxshow()
    },
    methods:{
        upyx(){
            var id = this.$route.params.id
            console.log(id)
             var data={
                "id":id,
                "yxname":this.yxname,
            }
            RI_yx_upd(data)
            .then(res=>{
                console.log(res)
            })
        },
        yxshow(){
            RI_res_yxsh()
            .then(res=>{
                console.log(res)
                this.yxlist=res
            })
        },
        upus(){
            var form_data= new FormData()
            form_data.append("username",this.username),
            form_data.append("password",this.password),
            form_data.append("ssd",this.ssd),
            form_data.append("img",this.file)
            console.log(form_data)
            axios({
                url:"http://127.0.0.1:8000/zks/usupt/",
                method:"post",
                data:form_data
            }).then(res=>{
                console.log(res.data)
            })
        },
        getfile(event){
            this.file = event.target.files[0]
            console.log(this.file);
            
        },   
    }
}
</script>

<style>

</style>
